package com.cskaoyan.controller;


import com.cskaoyan.bean.baseresultVO.BaseData;
import com.cskaoyan.bean.baseresultVO.BaseParam;
import com.cskaoyan.bean.baseresultVO.BaseRespVo;
import com.cskaoyan.bean.domain.Issue;
import com.cskaoyan.service.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 常见问题表 前端控制器
 * </p>
 *
 * @author looper
 * @since 2021-11-29
 */
@Controller
@RequestMapping("admin/issue")
public class IssueController {

    @Autowired
    IssueService service;

    @ResponseBody
    @GetMapping("list")
    public BaseRespVo<BaseData> getList(BaseParam param, String question) {
        BaseData baseData = service.getList(param, question);
        return BaseRespVo.ok(baseData);
    }

    @ResponseBody
    @PostMapping("create")
    public BaseRespVo<BaseData> createIssue(@RequestBody Issue issue) {
        Issue issue1 = service.createIssue(issue);
        return BaseRespVo.ok(issue1);
    }

    @ResponseBody
    @PostMapping("delete")
    public BaseRespVo<BaseData> deleteIssue(@RequestBody Issue issue) {
        service.deleteIssue(issue);
        return BaseRespVo.ok(null);
    }

    @ResponseBody
    @PostMapping("update")
    public BaseRespVo<BaseData> updateIssue(@RequestBody Issue issue) {
        Issue issue1 = service.updateIssue(issue);
        return BaseRespVo.ok(issue1);
    }


}

